

#ifndef __EV_FLASH_H__
#define __EV_FLASH_H__

#include <stdint.h>

#define FIMRWARE_MAGIC 0xA3BEA57C

typedef struct {
    uint8_t sha256[32];
    uint32_t magic;
    uint32_t size;
    uint32_t version;
    uint32_t dirty;
    uint32_t crc32;
} firm_info_t;

typedef enum {
    FIRMWARE_TYPE_BOOT,
    FIRMWARE_TYPE_APP1,
    FIRMWARE_TYPE_APP2
} firmware_type_t;

int ev_ota_erase(firmware_type_t type);
int ev_ota_write(firmware_type_t type, uint32_t offset, const uint8_t* data, uint32_t len);
int ev_ota_read(firmware_type_t type, uint32_t offset, uint8_t* data, uint32_t len);
int ev_ota_set_dirty(firmware_type_t type);
int ev_ota_check(firmware_type_t type);

#endif /* __EV_FLASH_H__ */
